From 017a62fa5a3b08ba9f9f014bcb46fa0db2e7e442 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 14 Jan 2008 18:52:55 +0000 Subject: [PATCH] Autopromotion: * Add APCOND_INGROUPS * Fix comment * Don't use array_unique() since we have groups as *keys* of $wgAutopromote --- RELEASE-NOTES | 1 + includes/Autopromote.php | 5 ++++- includes/Defines.php | 1 + includes/User.php | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6291317959..f4ceed6c71 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -132,6 +132,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 12536) User should be able to get MediaWiki version from any page * (bug 12622) A JavaScript constant to declare whether api.php is available * Add caching to the AJAX search +* Added APCOND_INGROUPS === Bug fixes in 1.12 === diff --git a/includes/Autopromote.php b/includes/Autopromote.php index 76d6f2ac0b..b509742331 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -18,7 +18,7 @@ class Autopromote { if( self::recCheckCondition( $cond, $user ) ) $promote[] = $group; } - return array_unique( $promote ); + return $promote; } /** @@ -98,6 +98,9 @@ class Autopromote { case APCOND_AGE: $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); return $age >= $cond[1]; + case APCOND_INGROUPS: + $groups = array_slice( $cond, 1 ); + return count( array_intersect( $groups, $user->getGroups() ) ) == count( $groups ); default: $result = null; wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), $user, &$result ) ); diff --git a/includes/Defines.php b/includes/Defines.php index 69096be3ae..1a62d45c54 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -282,3 +282,4 @@ define( 'RLH_FOR_UPDATE', 1 ); define( 'APCOND_EDITCOUNT', 1 ); define( 'APCOND_AGE', 2 ); define( 'APCOND_EMAILCONFIRMED', 3 ); +define( 'APCOND_INGROUPS', 4 ); \ No newline at end of file diff --git a/includes/User.php b/includes/User.php index 6734c322ee..08bf83c15e 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1639,8 +1639,8 @@ class User { /** * Get the list of implicit group memberships this user has. - * This includes all explicit groups, plus 'user' if logged in - * and '*' for all accounts. + * This includes all explicit groups, plus 'user' if logged in, + * '*' for all accounts and autopromoted groups * @param boolean $recache Don't use the cache * @return array of strings */ -- 2.20.1